﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MyDBconnection;


namespace CamposInventory
{
    public partial class frmViewmanager : Form
    {
        FrmMain parent;
        DatabaseConnection dbconn = new DatabaseConnection();
        
        public frmViewmanager(FrmMain p)
        {
            parent = p;
            InitializeComponent();
            this.Load +=new EventHandler(frmViewmanager_Load);
            txtsearch.TextChanged += new EventHandler(txtsearch_TextChanged);
            txtsearch.Click += new EventHandler(txtsearch_Click);
        }

        void txtsearch_Click(object sender, EventArgs e)
        {
            txtsearch.Text = "";
        }

        void txtsearch_TextChanged(object sender, EventArgs e)
        {
            if (txtsearch.Text != "")
            {
                DataView dw = new DataView(dbconn.tbl);
                dw.RowFilter = string.Format("Username LIKE '%{0}'", txtsearch.Text);
                dataGridView1.DataSource = dw;
            }
        }

        void frmViewmanager_Load(object sender, EventArgs e)
        {
            dbconn.dbconnection();
            dbconn.loadData("Select  distinct UserID , Name ,Username, Level , Datecreated from tbluser");
            dataGridView1.DataSource = dbconn.tbl;
            dbconn.DBClose();

        }

        private void txtsearch_TextChanged_1(object sender, EventArgs e)
        {

        }
    }
}
